<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
	<head>
		<%@ include file="/WEB-INF/jsp/inc/taglibs.jsp"%>
		<%@ include file="/WEB-INF/jsp/inc/meta.jsp"%>
		<script type="text/javascript"
			src="${approot}/resource/jquery/validate/jquery.validate.js"></script>
		<link href="${approot}/resource/jquery/validate/jquery.validate.css"
			rel="stylesheet" type="text/css" />
		<link href="${approot}/resource/jquery/validate/style.css"
			rel="stylesheet" type="text/css" />

		<script type="text/javascript">
	/* <![CDATA[ */
	jQuery(function() {
		jQuery("#prepaidName").validate( {
			expression : "if (VAL) return true; else return false;",
			message : "姓名不能为空"
		});

		jQuery('#prepaid').validated(function() {
			//alert("通过验证");
				do_edit();
			});
	});
	/* ]]> */
</script>

		<script type="text/javascript">
	function do_edit() {
		alert('aaaa');
		System.out.println('aaaa');
		var str = $('#prepaid').serializeObject();
		var jsons = $.toJSON(str);
		edit_prepaid(jsons);
	}

	function edit_prepaid(jsons) {
		alert('bbb');
		System.out.println('bbb');
		if(document.getElementById('prepaidName').value != '${prepaid.prepaidName}'){
			if(confirm("您修改了客户名称，系统默认为过户操作，如果确定请继续。")){
				$.ajax( {
					url : '${approot}/admin/prepaid/edit',
					dataType : 'json',
					contentType : 'application/json',
					data : jsons,
					type : 'post',
					beforeSend : function() {
						// $('#main').disabled='true';
					},
					error : function(request) {
						alert(S);
					},
					success : function(data) {
						if (data.msg == "error") {
							alert('修改失败，系统异常');
						}
						if (data.msg == "succ") {
							alert('客户信息修改成功。系统已默认收取30元过户费，如未收取，请在《额外费用管用系统》--《其他费用》板块删除此过户记录。');
							window.location.href = '${approot}/admin/prepaid/view/${prepaid.prepaidId}';
						}
					}
				});
			}
		}else{
		
		}
		
				
	}
</script>

	</head>
	<body style="background: #E8F5FE; padding: 15px 18px;" class="scroll_r">
		<div id="right_w">
			<p>
				当前位置：预付费用户管理 >>修改用户
			</p>
		</div>

		<form method="post" action="${approot}/admin/prepaid/edit"
			id="prepaid">
			<table border="0" cellpadding="0" cellspacing="1" width="92%"
				align="center" class="tab_l">
				<tr>
					<td>
						<b>请按要求填写：</b>
					</td>
					<td align="right">
						带
						<span style="color: #ff0000;">*</span>为必填
					</td>
				</tr>
			</table>
			<table border="0" cellpadding="0" cellspacing="1" width="92%"
				align="center" id="add_tab">


				<tr>
					<th width="20%">
						客户姓名：
					</th>
					<td width="30%">
						<input type="text" id="prepaidName" name="prepaidName"
							value="${prepaid.prepaidName }">
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>
				
					<th width="20%">
						表具：
					</th>
					<td width="30%">
						<input type="text" id="meterName" name="meterName"
							value="${prepaid.meterName }">
				<!--		<span style="color: #ff0000; margin: 0;">*</span>-->
					</td>
				</tr>

				<tr>
					<th>
						用气类型：
					</th>
					<td>
						<input type="text" name="prepaidType"
							value="${prepaid.prepaidType }" id="prepaidType">
			<!-- 			<span style="color: #ff0000; margin: 0;">*</span> -->
					</td>
				
					<th>
						气价：
					</th>
					<td>
						<input type="text" name="prepaidPrice"
							value="${prepaid.prepaidPrice }" id="prepaidPrice">
					</td>
				</tr>
				<tr>
					<th width="20%">
						用气地址：
					</th>
					<td colspan="3" width="80%">
						<input type="text" name="prepaidAddress"
							value="${prepaid.prepaidAddress }" id="prepaidAddress">
					</td>
				</tr>
				<tr>
					<th>
						联系电话：
					</th>
					<td>
						<input type="text" name="prepaidTel"
							value="${prepaid.prepaidTel }" id="prepaidTel">
					</td>
					<th>
						开户日期：
					</th>
					<td>
						<input type="text" name="createTime" disabled="disabled"
							value="<fmt:formatDate value="${prepaid.createTime}"
									pattern="yyyy-MM-dd HH:mm:ss" />" id="createTime">
					</td>
				</tr>
				<tr>
					<th width="20%">
						备注：
					</th>
					<td colspan="3">
						<input type="text" name="remark"
							value="${prepaid.remark }" id="remark">
					</td>
				</tr>
			</table>
			<p id="tab_but">
				<input type="hidden" name="prepaidId" value="${prepaid.prepaidId }"
					id="id">
				<input type="submit" value="修 改">&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="返 回" onclick="javascript:window.history.go(-1)">
			</p>
		</form>
	</body>
</html>
